package com.wangjiyuan.shiwupai.mine.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.wangjiyuan.shiwupai.R;
import com.wangjiyuan.shiwupai.base.BaseFragment;
import com.wangjiyuan.shiwupai.mine.activitiy.LoginActivity;
import com.wangjiyuan.shiwupai.mine.activitiy.MyCollectionActivity;
import com.wangjiyuan.shiwupai.mine.activitiy.MyOrderActivity;
import com.wangjiyuan.shiwupai.mine.activitiy.MyPhotoActivity;
import com.wangjiyuan.shiwupai.mine.activitiy.SettingActivity;
import com.wangjiyuan.shiwupai.mine.activitiy.UploadFoodDataActivity;

/**
 * A simple {@link Fragment} subclass.
 */
public class MineFragment extends BaseFragment implements View.OnClickListener{

    private LinearLayout ll_myPicture, ll_myCollection, ll_foodData, ll_myOrder;
    private ImageView img_setting, img_headImg;
    private Button btn_login;
    private TextView tv_mine_name;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_mine, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        ll_myPicture = (LinearLayout) view.findViewById(R.id.ll_myPicture);
        ll_myCollection = (LinearLayout) view.findViewById(R.id.ll_myCollection);
        ll_foodData = (LinearLayout) view.findViewById(R.id.ll_foodData);
        ll_myOrder = (LinearLayout) view.findViewById(R.id.ll_myOrder);

        img_setting = (ImageView) view.findViewById(R.id.img_setting);
        img_headImg = (ImageView) view.findViewById(R.id.img_headImg);
        tv_mine_name = (TextView) view.findViewById(R.id.tv_mine_name);

        btn_login = (Button) view.findViewById(R.id.btn_login);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        ll_myPicture.setOnClickListener(this);
        ll_myCollection.setOnClickListener(this);
        ll_foodData.setOnClickListener(this);
        ll_myOrder.setOnClickListener(this);
        img_setting.setOnClickListener(this);
        btn_login.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        Intent intent = new Intent();
        switch (view.getId()){
            case R.id.img_setting:
                intent.setClass(getActivity(), SettingActivity.class);
                break;
            case R.id.ll_myPicture:
                intent.setClass(getActivity(), MyPhotoActivity.class);
                break;
            case R.id.ll_myCollection:
                intent.setClass(getActivity(), MyCollectionActivity.class);
                break;
            case R.id.ll_foodData:
                intent.setClass(getActivity(), UploadFoodDataActivity.class);
                break;
            case R.id.ll_myOrder:
                intent.setClass(getActivity(), MyOrderActivity.class);
                break;
            case R.id.btn_login:
                intent.setClass(getActivity(), LoginActivity.class);
                break;
        }
        startActivity(intent);
    }
}
